<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>加法</title>
</head>
<body>
    <input type="number" id="firstNum" onkeyup="keyupHandle(event)" value="0">
    <span>+</span>
    <input type="number" id="secondNum" onkeyup="keyupHandle(event)" value="0">
    <span>=</span>
    <span id="res">0</span>
    <script>
        var firstNum = document.getElementById('firstNum')
        var secondtNum = document.getElementById('secondNum')
        var res = document.getElementById('res')
        function keyupHandle(e){
            var num1 = Number(firstNum.value)
            var num2 = Number(secondtNum.value)
            add(num1,num2)
        }
        function add(num1,num2){
            res.innerText = num1 + num2
        }
    </script>
</body>
</html>